﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZFSData.InterFace.User;

namespace ZFSData.Manager
{
    public class MenuManager : IMenu
    {
        public List<View_MenuTree> GetMenuTrees()
        {
            using (var db = new ZFSConfig())
            {
                var result = db.Database.SqlQuery<View_MenuTree>(
                    "SELECT a.isid, a.MenuName," +
                    " a.MenuCaption, a.ParentID, b.AuthorityName, b.AuthorityValue, a.MenuCode FROM " +
                    "dbo.tb_Menu AS a " +
                    "LEFT OUTER JOIN dbo.tb_AuthorityItem AS b ON b.AuthorityValue & " +
                    "a.MenuAuthorities = b.AuthorityValue").ToList();
                return result;
            }
        }

        /// <summary>
        /// 获取菜单列表
        /// </summary>
        /// <returns></returns>
        public List<tb_Menu> GetMenus()
        {
            using (var db = new ZFSConfig())
            {
                var result = db.tb_Menu.Where(t => true).ToList();
                return result;
            }
        }
    }
}
